<?php

$key0 = "";
if (!isset($_COOKIE['key1'])){

}else{
  $key0 = $_COOKIE['key1'];
}

// 产品
$hn_product = "HYSDZ00001";

// 产品类型
$hn_type = "";
if(isset($_POST['hn_type'])){
  $hn_type = $_POST['hn_type'];
}
// 数量
$hn_count = "";
if(isset($_POST['hn_count'])){
  $hn_count = $_POST['hn_count'];
}
// 名称
$hn_name = "";
if(isset($_POST['hn_name'])){
$hn_name = $_POST['hn_name'];
}

// 手机
$hn_phone = "";
if(isset($_POST['hn_phone'])){
$hn_phone = $_POST['hn_phone'];
}

// E-mail
$hn_email = "";
if(isset($_POST['hn_email'])){
$hn_email = $_POST['hn_email'];
}

// 详细
$hn_xx = "";
if(isset($_POST['hn_xx'])){
$hn_xx = $_POST['hn_xx'];
}

// 留言
$hn_ly = "";
if(isset($_POST['hn_ly'])){
$hn_ly = $_POST['hn_ly'];
}
/*
echo "1";
echo $hn_product;
echo "2";
echo $hn_type;
echo "3";
echo $hn_count;
echo "4";
echo $hn_name;
echo "5";
echo $hn_phone;
echo "6";
echo $hn_email;
echo "7";
echo $hn_xx;
echo "8";
echo $hn_ly;
*/

$ding_dan_id = "F1" . mt_rand(1,1000000000);
// 开DB连接
  $dbConnection = new PDO('mysql:dbname=firstpanda;host=127.0.0.1;charset=utf8', 'firstpanda', 'Apanda13689');
//$dbConnection = new PDO('mysql:dbname=firstpanda;host=127.0.0.1;charset=utf8', 'root', 'panda123');
$dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

//$stmt = $pdo->prepare('SELECT * FROM employees WHERE name = :name');
$stmt = $dbConnection->prepare('INSERT INTO ding_dan_biao (ding_dan_id,uname,chan_pin_id,fen_lei_id,shu_liang,xm,sj,em,xx,ly,chuang_jian_shi_jian) VALUES (:ding_dan_id,:uname,:chan_pin_id,:fen_lei_id,:shu_liang,:xm,:sj,:em,:xx,:ly,now())');
$stmt->execute(array(':ding_dan_id' => $ding_dan_id,':uname' => $key0,':chan_pin_id' => $hn_product,':fen_lei_id' => $hn_type,':shu_liang' => $hn_count,':xm' => $hn_name,':sj' => $hn_phone,':em' => $hn_email,':xx' => $hn_xx,':ly' => $hn_ly));
// 关DB连接
$dbConnection = null;


?>

<html>
<head>
  <meta charset="utf-8" />
  <!-- Facebook Pixel Code -->
  <script>
  !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', '1274057949323037');
  fbq('track', 'PageView');

  </script>
  <noscript>
  <img height="1" width="1" src="https://www.facebook.com/tr?id=1274057949323037&ev=PageView&noscript=1"/>

  </noscript>
  <!-- End Facebook Pixel Code -->
</head>
<body>


  </br></br>
  <div style="text-align:center;color:red;font-size:40px;">恭喜您，訂單提交成功，我們已經收到您的訂單，您的訂單編號为：<?php echo $ding_dan_id ?>,我们將盡快為您發出貨物。</div>
</br>
<div style="text-align:center;" ><a  href="../ObsidianPendant.php"><span style="font-size:40px;">點擊返回首頁</span></a></div>
<!-- Facebook Pixel Code -->
<script>
fbq('track', 'Purchase', {value: '1', currency:'USD'});
</script>
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1274057949323037&ev=Purchase&noscript=1&cd[value]=1&cd[currency]=USD" /></noscript>
<!-- End Facebook Pixel Code -->
</body>
</html>
